package com.ziyun.pop.rest.module.message;

import com.ziyun.pop.common.utils.UserUtils;
import com.ziyun.pop.modules.messageCenter.dto.MessageDto;
import com.ziyun.pop.modules.messageCenter.service.MessageCenterService;
import io.renren.common.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "MessageRestApi",tags = "客户留言")
@RestController
@RequestMapping("popApi/message/")
public class MessageRestApi {

    @Autowired
    private MessageCenterService messageCenterService;

    @ApiOperation(value = "获取当前商户的客户留言信息")
    @ApiResponses(value = @ApiResponse(code = 200, message = "查询客户留言成功"))
    @GetMapping(value = "/getMessageList")
    public R getUserMessageData(){
        return messageCenterService.getUserMessageData(UserUtils.getCurentUser().getSellerId());
    }

    @ApiOperation(value = "商户给用户留言!")
    @ApiResponses(value = @ApiResponse(code = 200,message = "留言成功",response = MessageDto.class))
    @PostMapping(value = "/sendMessage")
    public R sendMessage(@RequestBody MessageDto messageDto){
        return messageCenterService.leaveMessageToUser(messageDto);
    }
}
